package com.aaa.sm.controller;

import com.aaa.sm.entity.Vehicle;
import com.aaa.sm.service.VehicleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import com.aaa.common.util.BaseController;
import com.aaa.common.util.Result;
import com.aaa.common.vo.Page;


/**
 * 车辆(Vehicle)表控制层
 *
 * @author makejava
 * @since 2023-07-06 16:16:25
 */
@RestController
@RequestMapping("vehicle")
public class VehicleController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private VehicleService vehicleService;

    @GetMapping("queryA")
    public Result queryA(Integer id) {
        return success(this.vehicleService.queryA(id));
    }

    /**
     * 分页查询
     *
     * @param page 分页查询封装
     * @return 查询结果
     */
    @PostMapping("queryByPage")
    public Result queryByPage(@RequestBody Page<Vehicle> page) {
        return success(this.vehicleService.queryByPage(page));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("queryById")
    public Result queryById(Integer id) {
        return success(this.vehicleService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param vehicle 实体
     * @return 新增结果
     */
    @PostMapping("add")
    public Result add(@RequestBody Vehicle vehicle) {
        return success(this.vehicleService.insert(vehicle));
    }

    /**
     * 编辑数据
     *
     * @param vehicle 实体
     * @return 编辑结果
     */
    @PutMapping("edit")
    public Result edit(@RequestBody Vehicle vehicle) {
        return success(this.vehicleService.update(vehicle));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("deleteById")
    public Result deleteById(Integer id) {
        return success(this.vehicleService.deleteById(id));
    }

}

